import './index.scss'
import {View} from '@tarojs/components'
import {observer} from 'mobx-react'
import {useContext, useEffect} from 'react'
import Taro, {useDidHide, useDidShow, useRouter} from '@tarojs/taro'
import {userInfoStore} from './model'
import {InfoItem} from './components'
import {toEditNearName} from '@/utils/pageRedirect'

const Userinfo = () => {
  const {updatePageDataSource, pageData} = useContext(userInfoStore)

  // 可以使用所有的 React Hooks
  useEffect(() => {
    console.log('Userinfo useEffect')
  })
  // 对应 onShow
  useDidShow(() => {
    console.log('Userinfo useDidShow')
    updatePageDataSource()
  })
  // 对应 onHide
  useDidHide(() => {
    console.log('Userinfo useDidHide')
  })
  return (
    <View className="container">
      {/* <InfoItem label="头像" value="后续开放"></InfoItem> */}
      <InfoItem
        label="昵称"
        value={pageData.user?.userNearName || ''}
        isLast={true}
        onClick={() => toEditNearName()}
      ></InfoItem>
    </View>
  )
}
export default observer(Userinfo)
